package com.qk.mapper;

import com.qk.Dto.UserDto;
import com.qk.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> selectUserByList(UserDto userDto);
    @Insert("insert into user (username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time) " +
            "values (#{username},#{password},#{name},#{phone},#{email},#{gender},#{status},#{deptId},#{roleId},#{image},#{remark},#{createTime},#{updateTime})")
    void insertUser(User user);

    void deleteUserByIds(List<Integer> ids);
    @Select("select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time" +
            " from user where id=#{id}")
    User selectUserById(Integer id);

    void updateUser(User user);

    List<User> selectUserByRole(String roleLabel);
    @Select("select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time from user")
    void selectUserAll();
    @Select("select id, username, password, name, phone, email, gender, status, dept_id, role_id, image, remark, create_time, update_time from user" +
            " where dept_id=#{deptId}")
    List<User> findUserByDept(Integer deptId);
    @Select("select u.*,r.label roleLabel from user u,role r where u.role_id=r.id and username=#{username}")
    User loginUser(String username);
}
